package mockstudy;

import java.io.File;

/**
 * Created by zhifu on 2015/3/27.
 */
public class Demo {
    private String userName;
    private int userId;

    public static String generateRandomPrefix(){
        return "random";
    }

    private String toUpperCase(String str){
        return str.toUpperCase();
    }

    public int hackUserId(int userId) {
        return userId * 100 / 7;
    }

    public String displayFullUsername() {
        String fullUsername = generateRandomPrefix() + "_" + toUpperCase(userName) + "_" + hackUserId(userId);
        return fullUsername;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public boolean create(String directoryPath){
        File file  = new File(directoryPath);
        if(file.exists()){
            throw new IllegalArgumentException(
                    "\"" + directoryPath + "\" already exists.");
        }
        return file.mkdirs();
    }

    public boolean createDirectoryStructure(String path){
        if(create(path)){
            return true;
        }
        return false;
    }

}
